package com.geostar.gmp.init;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.geostar.gmp.model.factory.SessionFactory;
import com.geostar.gmp.scan.ScanService;

/**
 * 文件名:InitSystem.java
 * 功能: tomcat启动初始化系统
 * 目前支持方法
 * --------------------------------------
 * 初始版本 
 * 作者: yesong
 * 时间: Apr 10, 2014
 */
public class InitSystem extends HttpServlet{

	private static Logger logger = LoggerFactory.getLogger(InitSystem.class);
	
	//InitSystem 实行单例
	private static InitSystem initSystem = new InitSystem();
	
	public static InitSystem getInstance(){
		return InitSystem.initSystem;
	}
	
	private static final long serialVersionUID = -934908373072991133L;

	/**
	 * 	系统初始化
	 *  启动扫描引擎
	 */
	@Override
	public void init() throws ServletException {
		SqlSession session = null;
		super.init();
		try {
			
			//启动扫描引擎
			ScanService.getInstance().start();
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(">>>>>>>>>>>>>>扫描引擎启动异常<<<<<<<<<<<<<<");
		} finally {
			SessionFactory.closeSession(session);
		}
	}
}
